package com.link.play.fit.ai.ad

import android.content.Context
import com.google.android.gms.ads.MobileAds
import com.google.android.gms.ads.initialization.AdapterStatus
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch

object AdmobHelper {

    var isAdmobInit = false
        private set

    fun initAdmob(context: Context) = MainScope().launch(Dispatchers.Default) {
        MobileAds.initialize(context) {
            val readyAdapter = it.adapterStatusMap.entries.find { entry ->
                entry.value.initializationState == AdapterStatus.State.READY
            }
            if (readyAdapter != null) {
                isAdmobInit = true
            }
        }
    }
}